<?php
require_once("appinclude.php");
// establish link with mysql database
$link = @mysql_connect($GLOBALS["db_host"], $GLOBALS["db_user"], $GLOBALS["db_pass"]);
@mysql_select_db($GLOBALS["db_name"]);

$user = isset($_POST['fb_sig_user']) ? addslashes($_POST['fb_sig_user']) : NULL;
$cal_id = addslashes($_POST['friend_selector_id']);

$sem = $GLOBALS["semester"];
if(isset($_POST['sem']))
 $sem = addslashes($_POST['sem']);

$cal_res = mysql_query("SELECT cal_string from cal_strings WHERE semester='$sem' AND uid=$cal_id");
if($cal_id != NULL && mysql_num_rows($cal_res) != 0)
{
    while ($row = mysql_fetch_array($cal_res))
    {
        $cal_string = stripslashes($row['cal_string']);
        $url = $GLOBALS["full_callback"].'/phpicalendar/week.php?cal='.$GLOBALS["full_callback"].'/phpicalendar/reparse.php?cal='.$cal_string.'&getdate=20090825';
        $json = array (
            'success'=>'true',
            'url'=>$url
            );
        print json_encode($json);
    }
}
else
{
    $json = array (
        'success'=>'false',
        'url'=>''
        );
    print json_encode($json);
}

?> 